// 引入Service和请求头ServiceName
import { Service, ServiceName } from '@/network/http.js'
import store from '@/store/index.js' // 引入store

const api = {
  /**
     * 获取回款数据
     * @param {Object} params 检索条件的obj
     */
  reqGetCollections(params) {
    return Service.get(
      `/${ServiceName}/api/external/collection/queryall`,
      { params }
    )
  },
  /**
     * 新增回款数据
     * @param {Object} params 检索条件的obj
     */
  reqAddCollections(params) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/collection/insert`,
      params
    )
  },
  /**
     * 根据id查询回款
     */
  reqCollectionsById(id) {
    return Service.get(
      `/${ServiceName}/api/external/collection/querybyid?id=${id}`
    )
  },
  /**
     * 修改回款
     */
  reqCollectionsUpdate(params) {
    store.commit('changeStatus', true)
    return Service.put(
      `/${ServiceName}/api/external/collection/update`,params
    )
  },
  /**
   * 删除回款数据
   * @param {*} id 数据id
   */
  reqDeleteCollections(id) {
    return Service.delete(
      `/${ServiceName}/api/external/collection/deletebyid?id=${id}`
    )
  },
  /**
   * 修改状态
   */
  changeStatus(params) {
    store.commit('changeStatus', true)
    return Service.put(
      `/${ServiceName}/api/external/collection/updateStatus`,params
    )
  },
}
export default api
